import App from './App'
import config from './config'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'

import '@/permission.js'

import uView from "uview-ui";
Vue.use(uView);

// 配置请求拦截器
uni.addInterceptor('request', {
	invoke(args) {
		// 添加请求头
		args.header = {
			...args.header,
			'Content-Type': 'application/json',
			'X-Requested-With': 'XMLHttpRequest'
		}
		// 添加baseUrl
		if (!args.url.startsWith('http')) {
			args.url = config.baseUrl + args.url
		}
	}
})

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import uView from "uview-ui";

export function createApp() {
	const app = createSSRApp(App)
	app.use(uView)
	return {
		app
	}
}
// #endif